Reflection Desktop VBA Guide
Key Concepts / Understanding Syntax
In This Topic
    Understanding Syntax
    In This Topic

    Every keyword Help topic includes a syntax line that defines the syntax rules for that keyword. Following are some guidelines for understanding and using correct command syntax in your Visual Basic macros:

    The method and property signatures displayed in the Reflection VBA reference section typically refer to an object. For example:

    object.GetText 

    The syntax you use to reference the object in this signature depends on whether you are calling the method from a Reflection macro, a session created at runtime, or a macro developed in another application, like Excel.

    Let's take a look at how to use the syntax displayed in the Help for the GetText method.

    The Reflection VBA Help displays the following syntax for the GetText method:

    We can see at the top of the Help that this method is a member of the IbmScreen object so this is the type of object in the signature (displayed as object.GetText under Syntax).

    It's a good idea to verify this membership by looking at the member list for the object.


     If you are developing a macro for this session, you can use the ThisIbmScreen property to get this object.

    The syntax for using GetText in a session
    Copy Code
    'You can reference this object directly 
    Debug.Print ThisIbmScreen.GetText(1, 1, 50)
    
    'You can also reference it using a With statement
    With ThisIbmScreen
        .GetText(1,1,50)
    End With
    

        

    If you are developing a macro for a session that you create at runtime or a macro created from another application like Excel, you'll need to do a little more work to get the screen object before you call GetText.

    The syntax for using GetText in a session created at runtime
    Copy Code
    Private Sub CreateReflectionIBMSession()
      Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject
      
      'Declare frame, terminal, and view object variables:
      Dim frame As Attachmate_Reflection_Objects.frame
      Dim terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal
      Dim view As Attachmate_Reflection_Objects.view
      Dim screen As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmScreen
          
      'Create New instance of Reflection
      Set app = New Attachmate_Reflection_Objects_Framework.ApplicationObject
      
      With app
        'Wait until the Reflection is initalized
         Do While .IsInitialized = False
           .Wait 200
         Loop
          
         'Get a handle to the frame
         Set frame = .GetObject("Frame")
          
         'Make the frame visible so we can view the workspace
         frame.Visible = True
      End With
                            
      'Create an Ibm3270 control and set the host address
      Set terminal = app.CreateControl2("{09E5A1B4-0BA6-4546-A27D-FE4762B7ACE1}")
      terminal.HostAddress = "demo:ibm3270.sim"
      Set view = frame.CreateView(terminal)
      'Get the IbmScreen object
      Set screen = terminal.screen
      Debug.Print screen.GetText(1, 1, 50)
      '.........
    
    End Sub 
    

      

    The Reflection VBA Help displays the following syntax for the GetText method:

                   

    We can see at the top of the Help that this method is a member of the Screen object so this is the type of object in the signature (displayed as object.GetText under Syntax).

    Note: It's a good idea to verify this membership by looking at the member list for the object.

     If you are developing a macro for this session, you can use the ThisScreen property to get this object.

    The syntax for using GetText in a session
    Copy Code
    'You can reference this object directly 
    Debug.Print ThisScreen.GetText(1, 1, 50)
    
    'You can also reference it using a With statement
    With ThisScreen
        .GetText(1,1,50)
    End With
    
                   

    If you are developing a macro for a session that you create at runtime or a macro created from another application like Excel, you'll need to do a little more work to get the screen object before you call GetText. 

    The syntax for using GetText in a session created at runtime
    Copy Code
     Private Sub CreateReflectionOSSession()
        Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject
       
        'Declare frame, terminal, and view object variables:
        Dim frame As Attachmate_Reflection_Objects.frame
        Dim terminal As Attachmate_Reflection_Objects_Emulation_OpenSystems.terminal
        Dim view As Attachmate_Reflection_Objects.view
        Dim screen As Attachmate_Reflection_Objects_Emulation_OpenSystems.screen
         
        'Create New instance of Reflection
        Set app = New Attachmate_Reflection_Objects_Framework.ApplicationObject
     
        With app
             'Wait until Reflection is initalized
             Do While .IsInitialized = False
                 .Wait 200
             Loop
         
             'Get a handle to the frame
             Set frame = .GetObject("Frame")
         
             'Make the frame visible so we can view the workspace
             frame.Visible = True
         
         End With
                           
         'Create an Open Systems control and set the host address
         Set terminal = app.CreateControl2("{BE835A80-CAB2-40d2-AFC0-6848E486BF58}")
         terminal.ConnectionSettingsTelnet.HostAddress = "yourHostName"
         Set view = frame.CreateView(terminal)
         'Get the IbmScreen object
         Set screen = terminal.screen
         Debug.Print screen.GetText(1, 1, 50)
         '.........
    End Sub